import UniHelper from "@uni-helper/eslint-config";

// https://github.com/antfu/eslint-config
export default UniHelper({
  ignores: ["node_modules/**", "dist/**", "public/**", "static/**", "auto-import.d.ts", "components.d.ts", "uni-pages.d.ts", "paging.d.ts", "async-import.d.ts", "async-component.d.ts", "src/**/*.d.ts"],
  vue: true,
  jsonc: true,
  formatters: {
    css: true,
    html: false
  },
  lessOpinionated: true, // 允许使用箭头函数，如果关闭或删除此项 eslint 在检查时会自动将箭头函数转换为普通函数
  stylistic: {
    indent: 2,
    semi: true,
    blockSpacing: true,
    quotes: "double",
    quoteProps: "consistent-as-needed",
    commaDangle: "never",
    arrowParens: "always"
  },
  overrides: {
    vue: {
      "vue/operator-linebreak": "off",
      "vue/singleline-html-element-content-newline": "off",
      "vue/no-v-model-argument": "off",
      "vue/require-prop-types": "off",
      "vue/html-self-closing": "off",
      "vue/quote-props": "off",
      "vue/no-irregular-whitespace": "off",
      "vue/prop-name-casing": "off",
      "vue/html-indent": "off",
      "vue/no-reserved-component-names": "off",
      "vue/component-name-in-template-casing": "off",
      "vue/no-deprecated-slot-attribute": "off",
      "unused-imports/no-unused-vars": "off",
      "vue/no-unused-vars": "off",
      "vue/v-slot-style": "error", // 强制执行 v-slot 指令样式
      "vue/no-mutating-props": "error", // 不允许改变组件 prop
      "vue/custom-event-name-casing": "error", // 为自定义事件名称强制使用特定大小写
      "vue/html-closing-bracket-newline": "error", // 在标签的右括号之前要求或禁止换行
      "vue/attribute-hyphenation": "error", // 对模板中的自定义组件强制执行属性命名样式：my-prop="prop"
      "vue/attributes-order": "off", // vue api使用顺序，强制执行属性顺序
      "vue/no-v-html": "off", // 禁止使用 v-html
      "vue/require-default-prop": "off", // 此规则要求为每个 prop 为必填时，必须提供默认值
      "vue/multi-word-component-names": "off", // 要求组件名称始终为 “-” 链接的单词
      "vue/html-quotes": ["warn", "double", { avoidEscape: true }]
    },
    // https://eslint.style/
    stylistic: {
      "style/comma-dangle": ["error", "never"], // 禁止对象末尾自动补充逗号
      "style/max-statements-per-line": "off", // 函数括号内最多允许多少行
      "style/brace-style": ["error", "1tbs"], // 禁止 if else 多分支时 else 自动换行
      "style/arrow-parens": ["error", "always"], // 函数只有一个参数时保留括号
      "style/quote-props": ["error", "consistent-as-needed"], // 对象属性根据上下文智能添加引号
      "curly": "off", // 允许使用 if() return; 简写分支模式，开启的话会要求使用 if() { return; }
      "ts/no-use-before-define": "off", // 允许在定义变量之前使用变量
      "no-console": "off", // 允许使用 console
      "prefer-promise-reject-errors": "off" // 允许使用 new Promise(reject)
    }
  }
});
